package org.watchrecords;

import org.apache.wicket.Page;
import org.apache.wicket.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.apache.wicket.markup.html.WebPage;
import org.watchrecords.pages.MainPage;
import org.watchrecords.managers.UserManager;

import com.google.inject.Inject;
import com.wideplay.warp.persist.PersistenceService;

public class WatchRecordsApplication extends AuthenticatedWebApplication {
    private UserManager securityManager;
    
    @Inject
    public WatchRecordsApplication(PersistenceService service, UserManager securityManager) {
        service.start();
        this.securityManager = securityManager;
    }

    @Override
    protected void init() {
        super.init();
        getMarkupSettings().setStripWicketTags(true);
        getMarkupSettings().setDefaultBeforeDisabledLink("");
        getMarkupSettings().setDefaultAfterDisabledLink("");
        getSecuritySettings().setAuthorizationStrategy(new PermissionAuthorizationStrategy());
        
        securityManager.setup();
    }

    @Override
    public Class<? extends Page> getHomePage() {
        return MainPage.class;
    }

    @Override
    protected Class<? extends WebPage> getSignInPageClass() {
        return MainPage.class;
    }

    @Override
    protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
        return WatchRecordsSession.class;
    }

}
